﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business = JeanFish.Blog.Business;

namespace JeanFish.Blog.Web.Controls
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:Post runat=server></{0}:Post>")]
    public class Post : WebControl
    {
        public Post()
            :base("article")
        {

        }
        public Business.Post Data
        {
            get;
            set;
        }

        private Literal Title = new Literal();
        private Literal Text = new Literal();
        private Literal Author = new Literal();

        protected override void RenderContents(HtmlTextWriter output)
        {
            
            Title.Text = Data.Title;
            Text.Text = Data.Text;
            output.Write(@"<article class=""article""><h1>");
            Title.RenderControl(output);
            output.Write(@"</h1><section class=""article-meta""><dl><dt>作者</dt><dd>");
            Author.Text = Data.Author.Name;
            Author.RenderControl(output);
            output.Write(@"</dd></dl></section><section class=""article-text"">");
            Text.RenderControl(output);
            output.Write(@"</section></article>");
        }
    }
}
